home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / gui / gtlayout.lha / Source / LT_CreateHandle.c < prev    next >
C/C++ Source or Header  |  1998-09-09  |  16KB  |  623 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /*****************************************************************************/
  15.  
  16. #include <exec/memory.h>
  17.  
  18. #include <clib/keymap_protos.h>
  19. #include <pragmas/keymap_pragmas.h>
  20.  
  21. #include <stdarg.h>
  22.  
  23. /*****************************************************************************/
  24.  
  25. #include "Assert.h"
  26.  
  27. LayoutHandle * LIBENT
  28. LT_CreateHandle(REG(a0) struct Screen *Screen,REG(a1) struct TextAttr *Font)
  29. {
  30.     return(LT_CreateHandleTags(Screen,
  31.         LH_Font,Font,
  32.     TAG_DONE));
  33. }
  34.  
  35.  
  36. /*****************************************************************************/
  37.  
  38.  
  39. LayoutHandle *
  40. LT_CreateHandleTags(struct Screen *Screen,...)
  41. {
  42.     LayoutHandle    *Handle;
  43.     va_list          VarArgs;
  44.  
  45.     va_start(VarArgs,Screen);
  46.     Handle = LT_CreateHandleTagList(Screen,(struct TagItem *)VarArgs);
  47.     va_end(VarArgs);
  48.  
  49.     return(Handle);
  50. }
  51.  
  52.  
  53. /*****************************************************************************/
  54.  
  55.  
  56. /****** gtlayout.library/LT_CreateHandleTagList ******************************************
  57. *
  58. *   NAME
  59. *    LT_CreateHandleTagList -- Allocate auxilary data required by LT_New()
  60. *                              and LT_BuildA().
  61. *
  62. *   SYNOPSIS
  63. *    Handle = LT_CreateHandleTagList(Screen,Tags);
  64. *      D0                              A0    A1
  65. *
  66. *    LayoutHandle *LT_CreateHandleTagList(struct Screen *,struct TagItem *);
  67. *
  68. *    Handle = LT_CreateHandleTags(Screen,...);
  69. *
  70. *    struct LayoutHandle *LT_CreateHandleTags(struct Screen *,...);
  71. *
  72. *   FUNCTION
  73. *    Memory is allocated, tables are set up and data is collected
  74. *    on a screen a user interface is to be opened on. This
  75. *    involves calculating the screen font parameters.
  76. *
  77. *   INPUTS
  78. *    Screen - Pointer to the screen the user interface is to
  79. *        use. Passing NULL will cause the default public
  80. *        screen to be used.
  81. *
  82. *            NOTE: if NULL is passed the default public screen
  83. *                will stay locked until LT_DeleteHandle()
  84. *                is called.
  85. *
  86. *    Tags - Tag values to control certain aspects of the
  87. *        user interface created.
  88. *
  89. *
  90. *    Valid tags include:
  91. *
  92. *    LAHN_AutoActivate (BOOL) - Set to TRUE if you want the interface
  93. *        to always keep a string gadget active if possible. Hitting
  94. *        the return key will then cause the next following string
  95. *        gadget to get activated, either cycling through all the
  96. *        string gadgets available or stopping at the next string
  97. *        gadget to have the LAST_LastGadget attribute set.
  98. *        Default: TRUE
  99. *
  100. *    LAHN_RawKeyFilter (BOOL) - Discard unprocessed IDCMP_RAWKEY
  101. *        events. (V13)
  102. *        Default: TRUE
  103. *
  104. *    LAHN_UserData (APTR) - Store user specific data in the
  105. *        LayoutHandle->UserData entry.
  106. *
  107. *            NOTE: This tag requires gtlayout.library v9 and the
  108. *                corresponding entry in the LayoutHandle exists
  109. *                only under gtlayout.library v9 and up. *NEVER*
  110. *                write to this entry, use LT_SetAttributes()
  111. *                instead.
  112. *
  113. *    LAHN_LocaleHook (struct Hook *) - The hook to call when
  114. *        locale string IDs are to be mapped to strings. The
  115. *        hook function is called with the following parameters:
  116. *
  117. *        String = HookFunc(struct Hook *Hook,struct LayoutHandle *Handle,
  118. *          D0                            A0                         A2
  119. *                          LONG ID)
  120. *                               A1
  121. *
  122. *        The function is to look up the string associated with the ID
  123. *        passed in and return the string.
  124. *        Default: no locale hook
  125. *
  126. *    LAHN_TextAttr (struct TTextAttr *) - The text font to use when
  127. *        creating the gadgets and objects.
  128. *        Default: Screen->Font
  129. *
  130. *    LAHN_CloningPermitted (BOOL) - If a window will not fit onto the
  131. *        screen the user interface is intended for, the layout engine
  132. *        will scale the interface data down while stepping down in
  133. *        font size. If all this fails, the engine will open a custom
  134. *        screen for the window; this process is called "cloning".
  135. *        The LAHN_CloningPermitted tag controls whether the engine will
  136. *        actually try to open the custom screen or just return NULL
  137. *        when LT_Build fails.
  138. *        Default: TRUE
  139. *
  140. *    LAHN_EditHook (struct Hook *) - You can specify a default string
  141. *        gadget editing hook to be used for all following string
  142. *        gadgets. Your hook should obey the same rules that apply
  143. *        to hooks passed via GTST_EditHook/GTIN_EditHook.
  144. *        Default: NULL
  145. *
  146. *    LAHN_ExactClone (BOOL) - This tag works in conjunction with the
  147. *        LAHN_CloningPermitted tag. By default the layout engine will
  148. *        try to replicate only the basic characteristics of the
  149. *        screen the window was intended to open on. This may result
  150. *        in a screen which uses less colours than the original
  151. *        screen. You can force the engine to make an almost exact
  152. *        clone of the original screen by passing the LAHN_ExactClone
  153. *        tag with a value of TRUE.
  154. *        Default: FALSE
  155. *
  156. *    LAHN_MenuGlyphs (BOOL) - This tag will make the layout engine
  157. *        fill in the AmigaGlyph and CheckGlyph entries of the
  158. *        LayoutHandle if running under Kickstart 3.0 or higher.
  159. *        The corresponding images will be scaled to fit the actual
  160. *        screen aspect ratio values and can later be used for
  161. *        menu layout.
  162. *        Default: FALSE
  163. *
  164. *    LAHN_Parent (struct Window *) - You can pass a pointer to the
  165. *        parent window of the window you intend to open using
  166. *        the user interface layout engine. The new window will
  167. *        open inside the boundaries of the parent window. If the
  168. *        size does not fit, it will be opened centered over the
  169. *        parent window.
  170. *        Default: NULL
  171. *
  172. *    LAHN_BlockParent (BOOL) - This tag works in conjunction with the
  173. *        LAHN_Parent tag. If in effect, will block the parent window
  174. *        via LT_LockWindow until the new window is closed, after
  175. *        which the parent window is unlocked again.
  176. *        Default: FALSE
  177. *
  178. *    LAHN_SimpleClone (BOOL) - This tag works in conjunction with the
  179. *        LAHN_CloningPermitted tag. It will make the layout engine
  180. *        forget most information about the original screen the
  181. *        user interface was intended for. In short, it will open a
  182. *        simple default screen for the interface.
  183. *        Default: FALSE
  184. *
  185. *    LAHN_ExitFlush (BOOL) - When the LayoutHandle is finally disposed
  186. *        of with LT_DeleteHandle() all variables maintained by the
  187. *        input handling code will be flushed. For example, if you
  188. *        would use the LA_STRPTR tag for STRING_KIND objects the
  189. *        last string gadget contents would be copied into the buffer
  190. *        pointed to by LA_STRPTR. If you do not want to use this
  191. *        feature, disable it with "LAHN_ExitFlush,FALSE". (V9)
  192. *        Default: TRUE
  193. *
  194. *    LAHN_NoKeys (BOOL) - Use TRUE to tell the library not to pick
  195. *        keyboard shortcuts all on its own. This works like calling
  196. *        LT_New() for all objects with "LA_NoKey,TRUE,". (V26)
  197. *
  198. *    LAHN_PubScreen (struct Screen *) - Pointer to public screen
  199. *        window is to open on. Must be locked and open until you call
  200. *        LT_Built().
  201. *
  202. *    LAHN_PubScreenName (STRPTR) - Name of public screen to open window
  203. *        on. The library will try to lock the named screen as soon as
  204. *        you call LT_CreateHandle.
  205. *
  206. *    LAHN_PubScreenFallBack (BOOL) - If the named public screen cannot
  207. *        be found and you ask for it, the library will lock the default
  208. *        public screen (default: TRUE).
  209. *
  210. *    LAHN_TopGroupType (LONG) - Request that after creating the layout
  211. *        handle, a layout group should be added to it. This can be
  212. *        either a vertical or a horizontal group. You specify the type
  213. *        using VERTICAL_KIND or HORIZONTAL_KIND (default: don't add
  214. *        any group). (V45)
  215. *
  216. *   RESULT
  217. *    Handle - Pointer to a LayoutHandle structure.
  218. *
  219. ******************************************************************************
  220. *
  221. */
  222.  
  223. LayoutHandle * LIBENT
  224. LT_CreateHandleTagList(REG(a0) struct Screen *Screen,REG(a1) struct TagItem *TagList)
  225. {
  226.     LayoutHandle *    Handle;
  227.     struct Screen *    PubScreen;
  228.     APTR            Pool;
  229.     ULONG            WA_ScreenTag;
  230.     BOOL            UnlockThePubScreen;
  231.     LONG            TopGroupType = -1; 
  232.  
  233.     #ifdef DO_PICKSHORTCUTS
  234.     {
  235.         ObtainSemaphore(<P_KeySemaphore);
  236.  
  237.         if(!LTP_Keys[1])
  238.         {
  239.             UBYTE m